echo 'intersctions_and_unions';
cd $LOCALDIR
cd $METADATA_DIR
# ok first we need to sort them
t=$(mktemp);
cat $NHF | sort > $t;
cp $t $NHF
cat $RHF | sort > $t;
cp $t $RHF;
rm $t;
t=$(mktemp);
z=$(mktemp);
cat $RHF > $t;
cat $NHF >> $t;
cat $t | sort | uniq > $UNION
#get the intersection of the remote_hashes and the most_recent_local_hashes
cat $RHF | fgrep -f $NHF | sort | uniq > $INTER
cat $NHF | fgrep -f $RHF | sort | uniq > $INTER
cat $INTER > $z
cat $z | sort | uniq > $INTER
#empty the temp file
rm $z;touch $z;
cat $RHF | cut -f2 > $t #filenames only
cat $NHF | cut -f2 > $z
cat $RHF | fgrep -v -f $NHF | sort | uniq > $COMPLIMENT_REMOTE
cat $t | fgrep -v -f $z | sort | uniq | awk -F'*' '{print $2}' > $COMPLIMENT_REMOTE_FILES
cat $NHF | fgrep -v -f $RHF | sort | uniq > $COMPLIMENT_LOCAL
cat $z | fgrep -v -f $t | sort | uniq | awk -F'*' '{print $2}' > $COMPLIMENT_LOCAL_FILES
#now the symetric union
cat $RHF > $t;
cat $NHF >> $t;
cat $t | sort | uniq > $z;
cat $z | grep -v -f $COMPLIMENT_REMOTE | grep -v -f $COMPLIMENT_LOCAL  > $SYMETRIC_DIFFERENCE
#ok now the symetric 
rm $t;
rm $z;
